/**
  ******************************************************************************
  * @file    xxx.c 
  * @author  SD Electronics xxx
  * @version V1.0
  * @date    xx-xx-xx
  * @brief   xxxxxxxxxxxxxxxxxx.
  ******************************************************************************
  */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef _SD_AT_CMD
#define _SD_AT_CMD

/* Includes ------------------------------------------------------------------*/
#include "sd_common.h"

/** 
  * @brief  DefineSTENUM
  */
typedef uint8_t (*PFNAT_CmdReply)(void *pvHandle, uint8_t ulOption, uint8_t cmdIndex, uint8_t* param, int* ATCmdParamLen);
typedef uint8_t (*PFNAT_CmdProc)(void *pvHandle, void *pvdata, unsigned long uldatalen, unsigned char cmdIndex, uint8_t* param, int* ATCmdParamLen);
typedef long (*PFNAT_CmdValid)(void *pvHandle, uint8_t c);
typedef void (*PFNAT_CmdTaskInit)(void *pvHandle);
typedef void (*PFNAT_CmdTask_Do)(void *pvHandle, unsigned long ulOption,uint8_t TaskEvent);
/**
  * @}
  */

/** 
  * @brief  cmd_parser_state_t
  */ 
typedef enum
{
    /* BLE Slave */
	CMD_NAME = 0, 	
	CMD_MAC,
    CMD_BAUD,
    CMD_VER,
    CMD_PIN,
    CMD_MODE,
    CMD_TPMODE,
    CMD_REBOOT,
    CMD_RESTORE,
    CMD_UUID,
    CMD_RFDB,
    CMD_ADVINT,
    CMD_SLEEP,

    /* Mesh */
    CMD_MESH_DATA,
    CMD_MESH_REST,
    CMD_MESH_SETUP,
	CMD_MAX,
}EN_AT_CMDINDEX;


/** 
  * @brief  AT_CMD_REPLY
  */ 
typedef enum
{
    CMD_REPLY_READ_OK = 0x01,
    CMD_REPLY_WRITE_OK,
    CMD_REPLY_ERROR_FORMAT,
    CMD_REPLY_ERROR_PARAM,
    CMD_REPLY_ERROR_UNKNOW, 
}AT_CMD_REPLY;
/**
  * @}
  */


/** 
  * @brief  DefineSTENUM
  */ 
enum user_event_t 
{
    USER_EVT_AT_COMMAND,
    USER_EVT_UART_RECV, /*--->notify--->app---*/
    USER_EVT_APP_WRITE, /*BT write--->uart---*/
    USER_EVT_BUTTON,
    USER_EVT_HAND_FREQ, /*  */
    USER_EVT_DISPLAY_TM1621C,
    USER_EVT_FBLHilinkCMD,
};
/**
  * @}
  */

/** 
  * @brief  CMD
  */ 
typedef enum
{
	EN_CMD_QUERY,
	EN_CMD_SET,
}EN_CMDTYPE;
/**
  * @}
  */

/** 
  * AT命令初始化结果
  */
typedef enum
{
	EN_ATCMD_INIT_NULL        = -2, /*  */        
    EN_ATCMD_INIT_FAIL 	    = -1, /*  */        
	EN_ATCMD_INIT_SUCCESS   = 0,  /*  */       
}EN_ATCMD_INIT;   


/**
  * @}
  */


/** 
  * @brief  DefineSTENUM
  */ 
typedef struct
{
	uint8_t 		ucATCmdIndex;
    uint8_t   		ucErrorCode;        
    char*           ATCmdContent;//ָ
    }ST_AT_CMD, *PST_AT_CMD;
/**
  * @}
  */


typedef PST_AT_CMD (*PFNAT_CmdQuery)(void *pvHandle);
/** 
  * @brief  
  */ 
typedef struct
{
	uint8_t *pData;            	//
	unsigned long uldataLen;    //
}ST_AT_RECV_DATA, *PST_AT_RECV_DATA; 
/**
  * @}
  */

/** 
  * @定义 AT命令 管理结构体  
  */
typedef struct
{
    uint8_t                 ATCmdDevType; /* AT CMD对应的设备类型 BLE Mesh BT双模 */
    unsigned short 			usATCmdCount;
	uint8_t					ATCmdValid;
	uint16_t 				ATCmdTaskID;
	
    PST_AT_CMD 				pstATCmd;
	
	PST_AT_RECV_DATA 		pstATRecvData;
	
	PFNAT_CmdValid 			pfnATCmdValid;
	
	PFNAT_CmdQuery			pfnATCmdQuery;
	PFNAT_CmdTaskInit		pfnATCmdTaskInit;
	PFNAT_CmdTask_Do		pfnATCmdTaskDo;
    PFNAT_CmdProc           pfnATCmdProc;
	PFNAT_CmdReply			pfnATCmdReply;
	
}ST_AT_MANAGE_INFO, *PST_AT_MANAGE_INFO;
/**
  * @}
  */

/** @defgroup FunctionDeclaration
  * @{
  */ 
void SDAppATInit(void);

/**
  * @}
  */ 

#endif
/******************* (C) COPYRIGHT 2011 ShenZhenShiding electronics **************************/
